package net.mihome.app.bean;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import net.mihome.app.AppException;
import net.mihome.app.bean.Active.ObjectReply;
import net.mihome.app.bean.net.ResponsePojo;
import net.mihome.app.common.StringUtils;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.util.Xml;

/**
 * 动态列表实体类
 * @author liux (http://my.oschina.net/liux)
 * @version 1.0
 * @created 2012-3-21
 */
public class ActiveList extends Entity{

	public final static int CATALOG_LASTEST = 1;//最新
	public final static int CATALOG_ATME = 2;//@我
	public final static int CATALOG_COMMENT = 3;//评论
	public final static int CATALOG_MYSELF = 4;//我自己
	
	private int pageSize;
	private int activeCount;
	private List<Active> activelist = new ArrayList<Active>();
	private AdvertList adverts=new AdvertList(); //因为广告占用的是原来动态的空间，所以为了方便将广告放到这里。
	public int getPageSize() {
		return pageSize;
	}
	public int getActiveCount() {
		return activeCount;
	}
	public List<Active> getActivelist() {
		return activelist;
	}
	
	public AdvertList getAdverts() {
		return adverts;
	}
	public void setAdverts(AdvertList adverts) {
		this.adverts = adverts;
	}
	public static ActiveList parseAdvert(ResponsePojo responsePojo ) throws IOException, AppException {
		AdvertList advertList = new AdvertList();
		List list=(List) responsePojo.getData();
		if(list!=null&&!list.isEmpty()){
			Iterator iterator=list.iterator();
			while(iterator.hasNext()){
				Map map=(Map) iterator.next();
				Advert advert=Advert.parse(map);
				advertList.getAdvertList().add(advert);
			}
		}
		ActiveList activeList=new ActiveList();
		activeList.setAdverts(advertList);
        return activeList;       
	}
	public static ActiveList parse(ResponsePojo responsePojo ) throws IOException, AppException {
		ActiveList activeList = new ActiveList();
		List list=(List) responsePojo.getData();
		if(list!=null&&!list.isEmpty()){
			Iterator iterator=list.iterator();
			while(iterator.hasNext()){
				Map map=(Map) iterator.next();
				Active active=Active.parse(map);
				activeList.getActivelist().add(active);
			}
		}
        return activeList;       
	}
}
